import {
  createRouter,
  createWebHistory,
  createMemoryHistory,
} from "vue-router";
import type { Router } from "vue-router";
import { qiankunWindow } from "vite-plugin-qiankun/es/helper";

const router: Router = createRouter({
  history: qiankunWindow.__POWERED_BY_QIANKUN__
    ? createMemoryHistory("/microApp") // Memory基于内存，Web基于H5，微应用用Web会有重复调用路由bug
    : createWebHistory("/microApp"),
  routes: [
    {
      path: "/",
      name: "Layouts",
      component: () => import("@/layouts/index.vue"),
      redirect: "/home",
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/HomePage.vue"),
        },
        {
          path: "/test",
          name: "test",
          component: () => import("@/views/Test.vue"),
        },
      ],
    },
  ],
});
export default router;
